import matplotlib.pyplot as plt

# 数据准备
epochs = list(range(1, 21))  # 根据实际数据长度调整
train_loss_values = [0.6896540160162249, 0.5977078167437944, 0.23121712319860774, 0.05581629743535571, 0.0318968483944062, 0.02793060141921278, 0.015362876482315832, 0.01579478652451037, 0.012341231238472963, 0.007943660732199138, 0.007045045329842631, 0.011948730628416875, 0.01104095958800443, 0.008156635971831042, 0.0068428894228424065, 0.008943665067301517, 0.008136403516233171, 0.010266965915284719, 0.012159140206875222, 0.003945782426076923]
train_acc_values = [0.5425029515938606, 0.7061688311688312, 0.9353600944510035, 0.9874557260920898, 0.9946133412042503, 0.9957939787485242, 0.9972697756788665, 0.9973435655253837, 0.9973435655253837, 0.9983766233766234, 0.9987455726092089, 0.998155253837072, 0.998155253837072, 0.9987455726092089, 0.9989669421487604, 0.9983766233766234, 0.9988193624557261, 0.9986717827626919, 0.998155253837072, 0.9991145218417946]
test_loss_values = [0.6811683416366577, 0.6833841732570103, 1.723413781608854, 3.314751675299236, 3.9114560672215055, 4.119857669728143, 4.816990566253662, 4.856242626053946, 5.134201865536826, 5.0273303457668845, 4.804017513138907, 5.146539975915636, 5.691979736941201, 5.083567090545382, 4.986059195654732, 5.2738342830113005, 5.2429500682013375, 5.985688287871224, 4.999621595655169, 4.94318470954895]
test_acc_values = [0.5813873626373627, 0.5898351648351648, 0.5980769230769231, 0.5947802197802198, 0.5949862637362637, 0.6139423076923077, 0.5880494505494506, 0.6014423076923077, 0.6052197802197802, 0.6230082417582418, 0.6518543956043956, 0.6089972527472528, 0.5822115384615385, 0.6138736263736264, 0.6516483516483517, 0.5973901098901099, 0.5867445054945055, 0.540521978021978, 0.6206043956043956, 0.6135302197802198]
test_pre_values = [0.5714396310327787, 0.6555897374029839, 0.714343099960314, 0.6593967065630315, 0.619299547351873, 0.636333422854841, 0.6218286092733896, 0.6282588645214183, 0.6414715116032412, 0.6487861271676301, 0.6708921152202292, 0.6381205673758865, 0.618163964864672, 0.6414988009592326, 0.6703874660843094, 0.6270010727757207, 0.619406618193026, 0.5860960301875169, 0.6426407841243007, 0.6416137186581949]
test_rec_values = [0.5711508553654743, 0.6269448327000938, 0.645310418594274, 0.631610462560125, 0.6155301166079361, 0.6332460578380613, 0.6134679869546102, 0.6231913301966652, 0.6312922022954112, 0.6435714707561471, 0.6692324349863181, 0.631630148762066, 0.6085792468059137, 0.6355181736454253, 0.6689551876423148, 0.6204122946893189, 0.6118586399459286, 0.5733639125670151, 0.639521034706774, 0.6360185312780938]
test_f1_values = [0.5712719433424316, 0.5805984587637318, 0.5785752158031878, 0.5867595157182051, 0.5946868497443933, 0.6137872001784148, 0.5858961960025789, 0.60067819594416, 0.6028382003284708, 0.6214739080437617, 0.6516742782979126, 0.6075644473386959, 0.5789339009551577, 0.6122400437144417, 0.6516910315328422, 0.5956805019305018, 0.5852650400086984, 0.5329723306434722, 0.6200802181934864, 0.6132411291054676]

# 绘制曲线
plt.figure(figsize=(10, 6))

plt.plot(epochs, train_loss_values, label='Train Loss', marker='o')
plt.plot(epochs, train_acc_values, label='Train Accuracy', marker='o')
plt.plot(epochs, test_loss_values, label='Test Loss', marker='o')
plt.plot(epochs, test_acc_values, label='Test Accuracy', marker='o')
plt.plot(epochs, test_pre_values, label='Test Precision', marker='o')
plt.plot(epochs, test_rec_values, label='Test Recall', marker='o')
plt.plot(epochs, test_f1_values, label='Test F1', marker='o')

plt.title('Twitter Metrics over Epochs')
plt.xlabel('Epochs')
plt.xticks([0,5,10,15,20])
plt.ylabel('Metrics Value')
plt.legend()
plt.grid(True)
plt.tight_layout()

# plt.show()
plt.savefig('Twitter.png')

import matplotlib.pyplot as plt

# 数据准备
epochs = list(range(1, 21))  # 根据实际数据长度调整
train_loss_values = [0.6776197071882173, 0.4873806972878217, 0.22170424856543766, 0.185528935914862, 0.11701206382064819, 0.08097004438729673, 0.08532477040302557, 0.05594266352910983, 0.04861167978302008, 0.04322966416904044, 0.028709236238086678, 0.027105983354385348, 0.02224198467053908, 0.015553608124368155, 0.014600805568943337, 0.016139887376252816, 0.0076861062264054845, 0.008556296373213692, 0.010049687851578594, 0.009396683965967392]
train_acc_values = [0.5810989425981873, 0.7823829305135952, 0.9340067975830816, 0.959120090634441, 0.9770581570996979, 0.9858383685800605, 0.9865936555891238, 0.990464501510574, 0.9927303625377644, 0.9943353474320241, 0.9962235649546828, 0.9966956193353474, 0.9966012084592145, 0.9979229607250756, 0.9983950151057401, 0.9979229607250756, 0.998583836858006, 0.9992447129909365, 0.9986782477341389, 0.9986782477341389]
test_loss_values = [0.6598996999295982, 0.408908696706734, 0.6128185066379562, 0.8239913504329142, 1.0709532873855132, 1.253734007279402, 1.23976794187089, 1.3116653778182745, 1.523937216325131, 1.4063870851412692, 1.5145841594186038, 1.735052841428456, 1.7087552089817233, 1.5634300330479505, 1.8492989136719302, 1.5623761319401108, 1.8313441968597608, 1.7342071435379076, 1.638005438284153, 1.6486634671761897]
test_acc_values = [0.6023367117117117, 0.8572635135135135, 0.8809121621621622, 0.8833051801801801, 0.8824605855855855, 0.8817567567567568, 0.8851351351351351, 0.8885135135135135, 0.8754222972972973, 0.890625, 0.8841497747747747, 0.8744369369369369, 0.8745777027027027, 0.8872466216216216, 0.8723254504504504, 0.8921734234234233, 0.8737331081081081, 0.8844313063063064, 0.8889358108108109, 0.8883727477477477]
test_pre_values = [0.6979708534790701, 0.8583766008999654, 0.8837039931403514, 0.8834637939497274, 0.8859993403096196, 0.8872145518299364, 0.8852456662751933, 0.8917590532036199, 0.8818331338507421, 0.8910480711807913, 0.8894797070268597, 0.8849762994860871, 0.8843107441785063, 0.8914996692917168, 0.8871107279428772, 0.894383549666558, 0.8860580705141958, 0.8923005520184207, 0.8930743758014086, 0.8931634017779876]
test_rec_values = [0.6120861596127889, 0.8560381365039246, 0.8799013918620346, 0.8828308358909551, 0.8814660545568651, 0.8797444957401628, 0.8844728720157498, 0.886931627679055, 0.8732257842656832, 0.8898352805646541, 0.8823365056439618, 0.8718631521935367, 0.8719405256235009, 0.8854679802955665, 0.8692947841711156, 0.891013076109664, 0.8712721051590884, 0.8824117298119826, 0.8871873898503254, 0.8866737162458411]
test_f1_values = [0.5583148199514459, 0.8565331023590832, 0.880593505733645, 0.8830558781778294, 0.882223802976114, 0.880668051228799, 0.884734523427103, 0.8877305487116903, 0.8741510955611093, 0.8901978506772116, 0.8832591750989818, 0.8728628812553565, 0.8729330132413476, 0.8863446598891119, 0.8702711424849979, 0.8916900764414866, 0.8722763596173468, 0.8834430474301184, 0.8880623577783656, 0.8875833268487536]

# 绘制曲线
plt.figure(figsize=(10, 6))

plt.plot(epochs, train_loss_values, label='Train Loss', marker='o')
plt.plot(epochs, train_acc_values, label='Train Accuracy', marker='o')
plt.plot(epochs, test_loss_values, label='Test Loss', marker='o')
plt.plot(epochs, test_acc_values, label='Test Accuracy', marker='o')
plt.plot(epochs, test_pre_values, label='Test Precision', marker='o')
plt.plot(epochs, test_rec_values, label='Test Recall', marker='o')
plt.plot(epochs, test_f1_values, label='Test F1', marker='o')

plt.title('Weibo Metrics over Epochs')
plt.xlabel('Epochs')
plt.xticks([0,5,10,15,20])
plt.ylabel('Metrics Value')
plt.legend()
plt.grid(True)
plt.tight_layout()

# plt.show()
plt.savefig('Weibo.png')